import { requestClient } from '#/api/request';

export namespace AiKnowledgeCategoriesApi {
  /** 知识库分类信息 */
  export interface KnowledgeCategories {
    id: number; // 知识库分类id
    code?: string; // 分类编码
    name?: string; // 分类名称
    parentId?: number; // 父级分类ID
    description: string; // 分类描述
    icon: string; // 图标
    color: string; // 颜色
    status?: number; // 状态
    sort: number; // 排序
    codePath: string; // 分类路径
    path: string; // id路径
    systemFlag: boolean; // 是否系统内置
    knowledgeCount: number; // 知识库个数
    children?: KnowledgeCategories[];
  }
}

/** 查询知识库分类列表 */
export function getKnowledgeCategoriesList(data: any) {
  return requestClient.post<AiKnowledgeCategoriesApi.KnowledgeCategories[]>(
    '/ai/knowledge-categories/list',
    data,
  );
}

/** 查询知识库分类详情 */
export function getKnowledgeCategories(id: number) {
  return requestClient.get<AiKnowledgeCategoriesApi.KnowledgeCategories>(
    `/ai/knowledge-categories/get?id=${id}`,
  );
}

/** 新增知识库分类 */
export function createKnowledgeCategories(
  data: AiKnowledgeCategoriesApi.KnowledgeCategories,
) {
  return requestClient.post('/ai/knowledge-categories/create', data);
}

/** 修改知识库分类 */
export function updateKnowledgeCategories(
  data: AiKnowledgeCategoriesApi.KnowledgeCategories,
) {
  return requestClient.put('/ai/knowledge-categories/update', data);
}

/** 删除知识库分类 */
export function deleteKnowledgeCategories(id: number) {
  return requestClient.delete(`/ai/knowledge-categories/delete?id=${id}`);
}

/** 导出知识库分类 */
export function exportKnowledgeCategories(params: any) {
  return requestClient.download('/ai/knowledge-categories/export-excel', {
    params,
  });
}
